package com.situ.service.impl;

import java.util.List;

import com.situ.entity.SyEmp;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.situ.service.IvIninvoiceService;
import com.situ.dao.IvIninvoiceDao;
import com.situ.common.Assist;
import com.situ.entity.IvIninvoice;

<<<<<<< HEAD
=======
import java.util.*;

>>>>>>> 44fe0bde40fc461e32cae351c1883e6b70f9db82
/**
 * IvIninvoice的服务接口的实现类
 *
 * @author
 */
@Service
public class IvIninvoiceServiceImpl implements IvIninvoiceService {
<<<<<<< HEAD
=======

	
	@Override
	public List<Map> queryemp(){
		List<Map> map=ivIninvoiceDao.queryemp();
		return map;
	}

	
	
	
	
>>>>>>> 44fe0bde40fc461e32cae351c1883e6b70f9db82
    private final Logger LOG = LogManager.getLogger(this.getClass());

    @Autowired
    private IvIninvoiceDao ivIninvoiceDao;
    // TODO 当你看到这个方法时你应该创建一个工具类做通用的方法,定义自己的返回格式化
    private static final int C200 = 200;
    private static final int C412 = 412;

    public String resultFormat(int code, Object data) {
        JSONObject result = new JSONObject();
        result.put("code", code);
        if (data != null) {
            result.put("data", data);
        }
        return result.toJSONString();
    }


    @Override
    public IvIninvoice out(String StartNo, String EndNo) {
        return ivIninvoiceDao.out(StartNo, EndNo);
    }

    @Override
    public List<IvIninvoice> find(IvIninvoice value) {
        //TODO这里可以做通过Assist做添加查询
        List<IvIninvoice> result = ivIninvoiceDao.selectIvIninvoice(null);
        if (LOG.isDebugEnabled()) {
            LOG.debug("执行获取IvIninvoice数据集-->结果:", result);
        }
        return result;
    }

    @Override
    public IvIninvoice findOne(Object id) {
        if (id == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("执行通过IvIninvoice的id获得IvIninvoice对象-->失败:id不能为空");
            }
            return null;
        }
        IvIninvoice result = ivIninvoiceDao.selectIvIninvoiceById(id);
        if (LOG.isDebugEnabled()) {
            LOG.debug("执行通过IvIninvoice的id获得IvIninvoice对象-->结果:", result);
        }
        return result;
    }

    @Override
    public String saveNotNull(IvIninvoice value) {
        if (value == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("执行将IvIninvoice中属性值不为null的数据保存到数据库-->失败:对象不能为空");
            }
            return resultFormat(C412, null);
        }
        int result = ivIninvoiceDao.insertNotNullIvIninvoice(value);
        if (LOG.isDebugEnabled()) {
            LOG.debug("执行将IvIninvoice中属性值不为null的数据保存到数据库-->结果:", result);
        }
        return resultFormat(C200, result);
    }

    @Override
    public String updateNotNullById(IvIninvoice value) {
        if (value == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("执行通过IvIninvoice的id更新IvIninvoice中属性不为null的数据-->失败:对象为null");
            }
            return resultFormat(C412, null);
        }
        int result = ivIninvoiceDao.updateNotNullIvIninvoiceById(value);
        if (LOG.isDebugEnabled()) {
            LOG.debug("执行通过IvIninvoice的id更新IvIninvoice中属性不为null的数据-->结果:", result);
        }
        return resultFormat(C200, result);
    }

    @Override
    public String deleteById(Object id) {
        if (id == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("执行通过IvIninvoice的id删除IvIninvoice-->失败:id不能为空");
            }
            return resultFormat(C412, null);
        }
        int result = ivIninvoiceDao.deleteIvIninvoiceById(id);
        if (LOG.isDebugEnabled()) {
            LOG.debug("执行通过IvIninvoice的id删除IvIninvoice-->结果:", result);
        }
        return resultFormat(C200, result);
    }

    @Override
    public int insertIvIninvoice(IvIninvoice value) {
        return 0;
    }
<<<<<<< HEAD
=======

>>>>>>> 44fe0bde40fc461e32cae351c1883e6b70f9db82


}